<?php
	session_name("User");
	session_start();
	include ("../Conexciones/Conexcion.php");
	$Con=$Conexcion;
	if($_SESSION["Usuario"]==1)
	{
		$ID=$_SESSION['ID'];
		$FOrigen=$_POST["m_Flag"];
		if($FOrigen==3)
		{
			$Numproy=$_POST['m_NumProyecto'];
			CargarProyecto($Numproy);
		}
	}
	else
	{
				echo "<script>alert('Su Sesion no ha sido iniciada');
					  document.location.href='../index.html'</script>";
	}
	function Proyectos($_ID)
	{
		$_Con=$GLOBALS['Con'];
		
		$Sql=sprintf("Select count(*) as Numero from proyectos where idmaestro='%s'",$_ID);
		if($Result=pg_query($_Con,$Sql))
		{
			if($Row=pg_fetch_array($Result))
			{
				$NumProys=$Row['0'];
				print "$NumProys";
			}
		}
		else
		{
			print "<script>alert('Ocurrio un error al leer de la base de datos');</script>";
			$Error=pg_last_error($_Con);
			print $Error;
		}
	}
	
	function CargarProyecto($_NumProy)
	{
		$_Con=$GLOBALS['Con'];
		$Query=sprintf("Select tipo_proy,titulo,entidad,fecha_inicio,fecha_fin,area,diciplina,subdiciplina,sector,rama,clase from proyectos where clave='%s'",$_NumProy);
		if($Res=pg_query($_Con,$Query))
		{
			if($Row=pg_fetch_array($Res))
			{
				
			}
		}
		else
		{
			$Var=pg_last_error($_Con);
			$Error=sprintf("Ocurrio un error:<br>%s",$Var);
		}
		print"$var";
		
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PROYECTOS DE INVESTIGACION</title>
<link rel="stylesheet" href="../Estilos/Estilos.css" type="text/css">
<link rel="stylesheet" href="../Estilos/Est1.css" type="text/css">
<link href="../Estilos/calendario.css" type="text/css" rel="stylesheet">
<script src="../scripts/calendar.js" type="text/javascript"></script>
<script src="../scripts/calendar-es.js" type="text/javascript"></script>
<script src="../scripts/calendar-setup.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/Lib1.js"></script>
</head>
<body>
<table border="0" width="98%" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td><div class="Est1">EDITAR PROYECTOS</div></td><td><input type="button" onclick="RegresarMostrarTodo()" value="Volver" /></td>	
    </tr>
    <tr>
    	<td colspan="2">
    		<hr size="5" color="#333333"/>
		</td>
	</tr>
    <tr>
    	<td>
        	<Center>
            <form method="post" action="Editar.php">
            	<select name="m_NumProyecto">
                	 <?php
                    	$sql=sprintf("Select clave from proyectos where idmaestro='%s'",$ID);
						if($Arreglo=pg_query($Conexcion,$sql))
						{
							while ($Row=pg_fetch_array($Arreglo))
							{
								$NumProyecto=$Row[0];
								$Option=sprintf("<option selected='selected'>%s</option>",$NumProyecto);
								print "$Option";
							}
						}
						else
						{
							$Var=pg_last_error($Conexcion);
							$Error=sprintf("Ocurrio un error:<br>%s",$Var);
							print "$Error";
						}
					?>
                </select>
            	<input type="hidden" value="3" name="m_Flag" />
                <input type="submit" value="Editar Proyecto" />
            </form>
           
            </Center>
            <br />
        </td>
    </tr>
    <tr>
    	<td colspan="2">
        	<table border="1" width="100%" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
            	 <tr>
                	  <td colspan="4" style="border:thin solid #000">
                        <table border="0" bordercolor="#000000" width="100%" class="CabeceraPrincipal">
                            <tr>
                                <td width="33%">
                                    <div class="Est2"> Proyectos de Investigacion / Consultoria </div>
                                </td>
                                <td width="63%" align="right">
                                    
                                </td>
                                <td width="4%" align="right">&nbsp;</td>
                            </tr>
                        </table>
                      </td>
                 </tr>
                 <tr>
                 	<td width="14%">
                    	<form method="post" name="Proc" action="../Motor/Motor.php">
                            <table width="100%" cellpadding="0" cellspacing="0">
                              <tr>
                                <td><div class="Est3">
                                  <div align="right">Tipo de Proyecto:</div>
                                </div></td>
                                <td width="34%"><select name="m_TipoProy" id="m_TipoProy">
                                  <option>Investigación</option>
                                  <option>Consultoria</option>
                                  <option>Planeación</option>
                                </select></td>
                                <td width="20%"><div class="Est3">Fecha Inicio / Fecha Fin</div></td>
                                <td width="34%"><input type="text" name="m_FechaInicial" id="m_FechaInicial" readonly="readonly" />
                                  <img src="../imagenes/calendario.png" width="16" height="16" border="0" title="Fecha Inicial" id="FechIni" />
                                  <input type="text" name="m_FechaFinal" id="m_FechaFinal" readonly="readonly" />
                                  <img src="../imagenes/calendario.png" width="16" height="16" border="0" title="Fecha Final" id="FechFin" /></td>
                              </tr>
                            	<tr>
                            	  <td><div class="Est3">
                                    <div align="right">Titulo Proyecto:</div>
                                  </div></td>
                            	  <td colspan="3">
                           	      <input name="m_Titulo" onkeydown="return ValidarLetras(event)" type="text" id="m_Titulo" size="100" maxlength="100" /></td>
                           	  </tr>
                            	<tr>
                                	<td width="12%">
                                    	<div class="Est3">
                                    	  <div align="right">Entidad:</div>
                                    	</div>
                                    </td>
                                    <td colspan="3"><div class="Est3">
                                      <select name="m_Entidad" id="m_Entidad">
                                        <option>Institucion</option>
                                        <option>Empresa</option>
                                        <option>Act. Profecional</option>
                                      </select>
                                  </div></td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                    <BR />
                                    	<table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	OTRAS INSTITUCIONES / EMPRESAS PARTICIPANTES
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td width="4%"><br /><div class="Est3" align="right">1.- </div></td><td width="90%">
                                            	  <br /><input name="m_investi1" onkeydown="return ValidarLetras(event)" type="text" id="m_inst1" size="100" maxlength="100" /></td><td align="left"></td> <td align="center"></td>
                                            </tr>
                                            <tr id="Empresa1">
                                            	<td width="4%"><div class="Est3" align="right">2.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_investi2" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Empresa2">
                                            	<td width="4%"><div class="Est3" align="right">3.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_investi3" onkeydown="return ValidarLetras(event)" type="text" id="m_inst3" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Empresa3" >
                                            	<td width="4%"><div class="Est3" align="right">4.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_investi4" onkeydown="return ValidarLetras(event)" type="text" id="m_inst4" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Empresa4" >
                                            	<td width="4%"><div class="Est3" align="right">5.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_investi5" onkeydown="return ValidarLetras(event)" type="text" id="m_inst5" size="100" maxlength="100" />
                                                    </td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                        <table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	INVESTIGADORES PARTICIPANTES
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td width="4%"><br /><div class="Est3" align="right">1.- </div></td><td width="90%">
                                            	  <br /><input name="m_Inv1" onkeydown="return ValidarLetras(event)" type="text" id="m_inst1" size="100" maxlength="100" /></td><td align="left"></td> <td align="center"></td>
                                            </tr>
                                            <tr id="Investigador1" >
                                            	<td width="4%"><div class="Est3" align="right">2.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Inv2" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Investigador2" >
                                            	<td width="4%"><div class="Est3" align="right">3.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Inv3" onkeydown="return ValidarLetras(event)" type="text" id="m_inst3" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Investigador3" >
                                            	<td width="4%"><div class="Est3" align="right">4.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Inv4" onkeydown="return ValidarLetras(event)" type="text" id="m_inst4" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Investigador4" >
                                            	<td width="4%"><div class="Est3" align="right">5.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Inv5" onkeydown="return ValidarLetras(event)" type="text" id="m_inst5" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                        <table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	BECARIOS PARTICIPANTES
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td width="4%"><br /><div class="Est3" align="right">1.- </div></td><td width="90%">
                                            	  <br /><input name="m_becario1" onkeydown="return ValidarLetras(event)" type="text" id="m_inst1" size="100" maxlength="100" /></td><td align="left"></td> <td align="center"></td>
                                            </tr>
                                            <tr id="Becario1" >
                                            	<td width="4%"><div class="Est3" align="right">2.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_becario2" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Becario2" >
                                            	<td width="4%"><div class="Est3" align="right">3.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_becario3" onkeydown="return ValidarLetras(event)" type="text" id="m_inst3" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Becario3" >
                                            	<td width="4%"><div class="Est3" align="right">4.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_becario4" onkeydown="return ValidarLetras(event)" type="text" id="m_inst4" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr id="Becario4" >
                                            	<td width="4%"><div class="Est3" align="right">5.- </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_becario5" onkeydown="return ValidarLetras(event)" type="text" id="m_inst5" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                        <table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	AREA CONOCIMIENTO
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                             <tr>
                                            	<td width="4%"><div class="Est3" align="right">Area: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Area" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr >
                                            	<td width="4%"><div class="Est3" align="right">Disciplina: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Diciplina" onkeydown="return ValidarLetras(event)" type="text" id="m_inst3" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr >
                                            	<td width="4%"><div class="Est3" align="right">Subdisciplina: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Subdcpln" onkeydown="return ValidarLetras(event)" type="text" id="m_inst4" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                         <table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	ACTIVIDAD ECONOMICA
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                             <tr>
                                            	<td width="4%"><div class="Est3" align="right">Sector: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Sector" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr >
                                            	<td width="4%"><div class="Est3" align="right">Rama: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Rama" onkeydown="return ValidarLetras(event)" type="text" id="m_inst3" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr >
                                            	<td width="4%"><div class="Est3" align="right">Clase: </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Clase" onkeydown="return ValidarLetras(event)" type="text" id="m_inst4" size="100" maxlength="100" /></td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                         <table border="0" width="95%" align="center" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border:medium solid #000">
                                            <tr class="CabeceraCelda">
                                            	<td colspan="4">
                                                	PRINCIPALES LOGROS / PRODUCTO FINAL OBTENIDO
                                                </td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                             <tr>
                                            	<td width="4%"><div class="Est3" align="right">&nbsp; </div></td><td width="90%" colspan=3>
                                            	  	<input name="m_Logro" onkeydown="return ValidarLetras(event)" type="text" id="m_inst2" size="180" maxlength="180" /></td>
                                            </tr>
                                            <tr>
                                            	<td>&nbsp;</td>
                                              <td colspan=3>&nbsp;</td>
                                            </tr>
                                        </table>
                                        <br />
                                        <input type="hidden" name="m_Flag" value="2" />
                                        <?php 
											$Control=sprintf("<input type='hidden' name='m_IdPro' value='%s'>",$ID);
											print "$Control";
										?>
                                        <center><input type="submit" name="BttAcept" onclick="return ValidarForm1()" value="Actualizar"/></center>
                                        <br />
                                    <td>
                                </tr>
                        	</table>
                    	</form>
                    </td>
                 </tr>
                 <tr>
                 </tr>
            </table>
        </td>
    </tr>
</table>
<p><!-- script que define y configura el calendario--> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "m_FechaInicial",     // id del campo de texto 
     ifFormat     :     "%d-%m-%Y",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "FechIni"     // el id del botón que lanzará el calendario 
}); 
  </script>
</p>
<script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "m_FechaFinal",     // id del campo de texto 
     ifFormat     :     "%d-%m-%Y",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "FechFin"     // el id del botón que lanzará el calendario 
}); 
  </script>
</body>
</html>
